import pygame, time, random
from pygame.sprite import Sprite
from Map import Map


class BaseItem(Sprite):
    """base sprite class abstract"""
    def __init__(self):
        super(BaseItem, self).__init__()
        self.img = None
        self.rect = pygame.rect.Rect(0,0,0,0)
        # 是否透明
        self.transparent = False

    def display(self):
        Map.window.blit(self.image,self.rect)

    def hit(self,target):
        return pygame.sprite.collide_rect(self, target)

    def setTransparent(self):
        self.transparent = not self.transparent
        self.rect.width = (1-self.transparent)*self.image.get_rect().width
        self.rect.height = (1-self.transparent)*self.image.get_rect().height




